package com.powernode.shop.controller;

import com.powernode.shop.domain.SysRole;
import com.powernode.shop.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZHAOZHENYU
 * @since 2022/10/11
 */

@RestController
@RequestMapping("/sys/role")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 列出role 前端添加用户数据回显
     * @return
     */
    @PreAuthorize("hasAuthority('sys:role:list')")
    @GetMapping("/list")
    public ResponseEntity<List<SysRole>> listRole(){
        List<SysRole> sysRoleList = sysRoleService.list();
        return ResponseEntity.ok(sysRoleList);
    }

}
